package top.arryweb.application.domain.pojo;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import top.arryweb.application.domain.dto.CreateCapitalBlotterDTO;

/**
 * <p>
 * 资金流水表
 * </p>
 *
 * @author Mac
 * @since 2021-05-28
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class BookKeepCapitalBlotter implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long id;

    private Long createBy;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    private Boolean deleteFlag;

    private Boolean enableFlag;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.UPDATE)
    private LocalDateTime updateTime;

    private Long version;

    private BigDecimal amount;

    /**
     * 流水类型(收入，支出)
     */
    private String capitalType;

    /**
     * 商户id
     */
    private Long merchantId;

    /**
     * 订单id
     */
    private Long orderId;

    /**
     * 支付时间
     */
    private LocalDateTime payTime;

    /**
     * 备注
     */
    private String remark;

    /**
     * 交易流水id
     */
    private Long tradeBlotterId;

    /**
     * 用户id
     */
    private Long userId;

    /**
     * 流水类型(支付，退款)
     */
    private String payType;

    /**
     * 收益记录类型id，收益记录一般有使用者自己创建，若没有值，则默认为0
     */
    private Long capitalDailyTapeId;

    /**
     * 数据校验--创建资金流水ID
     */
    public BookKeepCapitalBlotter(CreateCapitalBlotterDTO dto) {
        this.setMerchantId(dto.getMerchantId());
        this.setUserId(dto.getUserId());
        this.setAmount(dto.getAmount());
        this.setPayType(String.valueOf(dto.getPayType()));
        this.setRemark(dto.getRemark());
    }
}
